package priv.abadstring.study.haoke.webapi.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.io.File;

import static priv.abadstring.study.haoke.webapi.manage.ImageManageByFileSystem.IMAGE_ROOT_FOLDER;

/**
 * WebMvcConfig
 *
 * @author aBadString
 * @date 2021-06-15 18:44:35
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 将 /image/ 下所有请求映射到本地文件
        registry.addResourceHandler("/image/**")
                .addResourceLocations("file:" + IMAGE_ROOT_FOLDER +  File.separator);
    }
}
